
enum AHTXX_LIST {
    //% block="AHT2X"
     AHT2x_SENSOR,
    //% block="AHT1X"
     AHT1x_SENSOR
}

enum FUN_LIST {
    //% block="湿度(%rh)"
     readHumidity,
    //% block="温度(℃)"
     readTemperature
}



//% color="#5ba55b" iconWidth=50 iconHeight=40
namespace AHTxx_Sensor { 

    //% block="读取数字温湿度传感器 [AHTXX] 的 [FUN]" blockType="reporter"
    //% AHTXX.shadow="dropdown" AHTXX.options="AHTXX_LIST" 
    //% FUN.shadow="dropdown" FUN.options="FUN_LIST" 
     export function read_ahtxx(parameter: any, block: any) {
        let ahtxx = parameter.AHTXX.code;
        let fun = parameter.FUN.code;
        Generator.addInclude('#include_Wire_h>', '#include <Wire.h>');
        Generator.addInclude('#include_RL_AHTxx_h', '#include <RL_AHTxx.h>');
        Generator.addObject(`AHTxx_aht`, `AHTxx`, `aht(AHTXX_ADDRESS_X38, ${ahtxx});`);
        Generator.addSetup(`aht_begin`, `aht.begin();`);
        Generator.addCode(`aht.${fun}()`);
    }

   
}
